//cert-fx.com////////////////////////////////////////////////////|
#import "kernel32.dll"
void GetLocalTime(int& TimeArray[]);
#import "xxxXXXxxx"//DLL̖O
//-------------------------------------------------------------------------------------------------
int Inspection();
string Check_Account(int Account_Number, string Mq45, string EaCode, string Url, string AccountName, string AccountCompany, bool isDemo);
//-------------------------------------------------------------------------------------------------
#import
string AuthURL = "xxxURLxxx";//ɔF؃t@CURL
string EA_Code = "xxxEACxxx";//EA(̓CW)̌ŗLID
int AccountCertification = -1;
int cntCheckAccount = -100;
string AccountGetTime;
datetime AccountEndTime;
//----
string FormatDateTime(int nYear,int nMonth,int nDay,int nHour,int nMin) {
    string sMonth,sDay,sHour,sMin;
    sMonth=IntegerToString(100+nMonth);
    sMonth=StringSubstr(sMonth,1);
    sDay=IntegerToString(100+nDay);
    sDay=StringSubstr(sDay,1);
    sHour=IntegerToString(100+nHour);
    sHour=StringSubstr(sHour,1);
    sMin=IntegerToString(100+nMin);
    sMin=StringSubstr(sMin,1);
    return(StringConcatenate(nYear,".",sMonth,".",sDay," ",sHour,":",sMin));//,":",sSec));
}
//----
datetime Local_Time() {
    int    TimeArray[4];
    int    nYear,nMonth,nDay,nHour,nMin;
    GetLocalTime(TimeArray);
    nYear=TimeArray[0]&0x0000FFFF;
    nMonth=TimeArray[0]>>16;
    nDay=TimeArray[1]>>16;
    nHour=TimeArray[2]&0x0000FFFF;
    nMin=TimeArray[2]>>16;
    string LocalTimeS = FormatDateTime(nYear,nMonth,nDay,nHour,nMin);
    datetime cltLocalTime = StrToTime( LocalTimeS );
    return(cltLocalTime);
}
//----
void CheckAuthAccount(bool flgAlert){

    AccountGetTime = Check_Account(AccountNumber(), __FILE__, EA_Code, AuthURL, AccountName(), AccountCompany(), IsDemo());

    if (StringLen(AccountGetTime) < 8)
    {
        AccountCertification = StrToInteger(AccountGetTime);
        AccountEndTime = D'1977.11.11 11:11';
    } else
    {
        AccountCertification = 123;
        AccountEndTime = StrToTime(AccountGetTime);
    }
        datetime cltLocalTime = Local_Time();

    if( cltLocalTime > AccountEndTime || TimeCurrent() > AccountEndTime ) {
        if (AccountCertification > 0)
            AccountCertification = -10;
    }

    string strAlert, ex4Name = WindowExpertName();
    switch(AccountCertification) {
        case -1000:printf("Fؕs:"+ex4Name+"o^𒴉");strAlert="The number of registration is exceeded. ";break;
        case  -400:printf("Fؕs:"+ex4Name+"Demos");strAlert="In the demonstration account, it is not possible to use it. ";break;
        case  -350:printf("Fؕs:"+ex4Name+"EA CodeႢ");strAlert="The EA codes other than the specification cannot use this program. ";break;
        case  -300:printf("Fؕs:"+ex4Name+"u|J[ԈႢ");strAlert="Brokers other than specification cannot use this program. ";break;
        case  -200:printf("Fؕs:"+ex4Name+"AJEgSs");strAlert="The specification of the account name is different. ";break;
        case  -202:printf("Fؕs:"+ex4Name+"AJEgPs");strAlert="A part of specification of the account name is different. ";break;
        case  -100:printf("Fؕs:"+ex4Name+"AccountNo.s");strAlert="The specification of the accounting number is different. ";break;
        case   -10:printf("Fؕs:"+ex4Name+"؂");strAlert="The time limit of EA cuts. ";break;
        case    -1:printf("Fؕs:"+ex4Name+"o^݂܂");strAlert="There is no registration. ";break;
    }
        ObjectSetText("label_EndTime", "", 24, "Times New Roman", clrOrangeRed);
    if (AccountCertification<0) {
        ObjectSetText("label_EndTime", strAlert, clrOrangeRed);//Yellow Red
        if (flgAlert) Alert(strAlert);
    }
}
//cert-fx.com////////////////////////////////////////////////////|
